<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>支付跳转中...</title>
    <style>
        body {
            font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
            margin: 0;
            background: linear-gradient(135deg, #ffe60f 0%, #ffd700 100%);
        }
        
        .loading-container {
            text-align: center;
            padding: 40px;
            background: white;
            border-radius: 20px;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
        }
        
        .spinner {
            width: 60px;
            height: 60px;
            border: 4px solid #f3f3f3;
            border-top: 4px solid #ffe60f;
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin: 0 auto 20px;
        }
        
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        
        .message {
            font-size: 1.2rem;
            color: #333;
            margin-top: 20px;
        }
    </style>
</head>
<body>
    <div class="loading-container">
        <div class="spinner"></div>
        <div class="message">正在跳转到支付页面...</div>
    </div>

    <script th:inline="javascript">
        const orderId = /*[[${orderId}]]*/ '';
        
        // 检测用户代理
        const userAgent = navigator.userAgent.toLowerCase();
        
        // 判断是否在微信内置浏览器
        const isWechat = userAgent.indexOf('micromessenger') !== -1;
        
        // 判断是否在支付宝内置浏览器
        const isAlipay = userAgent.indexOf('alipayclient') !== -1;
        
        // 根据浏览器类型跳转
        if (isWechat) {
            // 微信浏览器，跳转到微信支付页面
            window.location.href = '/pay/wechat/' + orderId;
        } else if (isAlipay) {
            // 支付宝浏览器，跳转到支付宝支付
            const form = document.createElement('form');
            form.method = 'POST';
            form.action = '/pay/alipay/' + orderId;
            document.body.appendChild(form);
            form.submit();
        } else {
            // 普通浏览器，跳转回聚合支付页面
            alert('请使用微信或支付宝扫描二维码进行支付');
            window.location.href = '/pay/union/' + orderId;
        }
    </script>
</body>
</html>

